/**
 * 相关路由
 *  通用
 *      消息通知 本期不做
 *      登录注册
 *      落地页
 *      个人中心
 *      账号资产
 *  联盟伙伴
 *      数据总览
 *      佣金历史
 *      订单明细
 *      营销链接
 *  管理员
 *      数据总览
 *      佣金历史
 *      订单明细
 *      角色申请审核
 *      账号管理
 *      提现记录
 * */

import { lazy } from 'react'

// 布局组件
const LayoutMain = lazy(() => import('@/layout/main'))
const LayoutNormal = lazy(() => import('@/layout/normal'))

// 通用
const Home = lazy(() => import('@/pages/home'))
const Page404 = lazy(() => import('@/pages/404'))
const Login = lazy(() => import('@/pages/login'))
const Account = lazy(() => import('@/pages/account'))
const Asset = lazy(() => import('@/pages/asset'))
const CommWithdrawal = lazy(() => import('@/pages/withdrawal'))

// 数据统计
const Brokerage = lazy(() => import('@/pages/statistic/brokerage'))
const Order = lazy(() => import('@/pages/statistic/order'))
const Overview = lazy(() => import('@/pages/statistic/overview'))

// 营销工具
const Marketing = lazy(() => import('@/pages/market/link'))

// 角色管理
const Apply = lazy(() => import('@/pages/role-manage/apply'))
const RoleAccount = lazy(() => import('@/pages/role-manage/account'))

// 分成管理
const Withdrawal = lazy(() => import('@/pages/share-manage/withdrawal'))

// 申请页面
const ApplyRole = lazy(() => import('@/pages/apply-role'))

// 公共路由
const commRoutes = [
  {
    name: '首页',
    path: '/',
    extract: true,
    element: <Home />,
  },
  {
    name: '登录',
    path: '/login',
    element: <Login />,
  },
  {
    name: '个人中心',
    path: '/account',
    element: <LayoutNormal />,
    children: [
      {
        name: '个人中心',
        path: '',
        element: <Account />,
      },
    ],
  },
  {
    name: '账户资产',
    path: '/asset',
    element: <LayoutNormal />,
    children: [
      {
        name: '账户资产',
        path: '',
        element: <Asset />,
      },
    ],
  },
  {
    name: '提现记录',
    path: '/withdrawal',
    element: <LayoutNormal />,
    children: [
      {
        name: '提现记录',
        path: '',
        element: <CommWithdrawal />,
      },
    ],
  },

  {
    path: '*',
    element: <Page404 />,
  },
]

/**
 * 0 :未开通 1：管理员 2 ：联盟伙伴
 * */
const routes = {
  0: [
    ...commRoutes,
    {
      path: '',
      element: <LayoutMain />,
      children: [
        {
          name: '申请角色',
          path: 'market-center',
          element: <ApplyRole />,
        },
      ],
    },
  ],
  1: [
    ...commRoutes,
    {
      name: '营销中心',
      path: 'market-center',
      element: <LayoutMain />,
      children: [
        {
          name: '数据总览',
          path: '',
          extract: true,
          element: <Overview />,
        },
        {
          name: '佣金历史',
          path: 'brokerage',
          element: <Brokerage />,
        },
        {
          name: '订单明细',
          path: 'order',
          element: <Order />,
        },
        {
          name: '角色申请审核',
          path: 'role',
          element: <Apply />,
        },
        {
          name: '账号管理',
          path: 'account',
          element: <RoleAccount />,
        },
        {
          name: '提现记录',
          path: 'withdrawal',
          element: <Withdrawal />,
        },
      ],
    },
  ],
  2: [
    ...commRoutes,
    {
      name: '营销中心',
      path: 'market-center',
      element: <LayoutMain />,
      children: [
        {
          name: '数据总览',
          path: '',
          element: <Overview />,
        },
        {
          name: '佣金历史',
          path: 'brokerage',
          element: <Brokerage />,
        },
        {
          name: '订单明细',
          path: 'order',
          element: <Order />,
        },
        {
          name: '营销链接',
          path: 'link',
          element: <Marketing />,
        },
      ],
    },
  ],
}

export default routes
